#pragma once
#include <string>
#include <list>
#include<map>
#include <iomanip>

using namespace std;

class Parser;

enum TokenTypes{
	PREDEFINED = 0, // Should always be first
	IFELSE,
	KEYWORDS1,
	KEYWORDS2,
	OPERATORS,
	BRACKETSCURLY,
	BRACKETSSQUARE,
	BRACKETSCIRCLE,
	MAIN,
	NONE // should always be last
};

class Analyze {
public:
	Analyze();
	virtual ~Analyze();
	virtual void compileLine(const list<const string *>& line);
	virtual void finishCompile();
	const list<const string *>& getErrors() const;
	const list<const string *>& getVarsAndFuncs() const;
	
	/*consts*/
	static const int NOF_LISTS = 9;	
protected:
	virtual TokenTypes getTokenType(const string& token) const;
	virtual void initFields();
	virtual void destroyFields();

private:
	int nofLine;
	list<const string *> errors;
	list<const string *> varsAndFuncsLst;
	map<const string, const string> varsAndFuncsMap;
	// Counters
	int nofbracketsCircle;
	int nofbracketsCurly;
	int nofbracketsSquare;
	int nof_if;

	int mainFlag;
	TokenTypes lastTokenType;
	const string *lastToken;

	list<const string> *predefinedType;
	list<const string> *keywordsGroup1;
	list<const string> *keywordsGroup2;
	list<const string> *operands;
	list<const string> *ifElse;
	list<const string> *bracketsCurly;
	list<const string> *bracketsSquare;
	list<const string> *bracketsCircle;
	list<const string> *mainLine;
	list<const string>* arr[NOF_LISTS];
};